import 'dart:typed_data';

(int redLedData, int irLedData) parsePpgData(Uint8List data) {
  // 从前3个字节解析 red LED 数据
  final redLedData = (data[0] << 16) | (data[1] << 8) | data[2];
  // 从后3个字节解析 IR LED 数据
  final irLedData = (data[3] << 16) | (data[4] << 8) | data[5];
  return (redLedData, irLedData);
}

// void main() {
//   // 测试数据 - 与 Python 中的 bytes 等价
//   final testData = Uint8List.fromList([0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC]);
  
//   // 运行解析
//   final (redLedData, irLedData) = parsePpgData(testData);
  
//   // 打印结果
//   ('Red LED Data: ${redLedData.toRadixString(16).toUpperCase()} ($redLedData)');
//   print('IR LED Data: ${irLedData.toRadixString(16).toUpperCase()} ($irLedData)');
  
//   // 与 Python 结果比较
//   // Python: red_led_data = int.from_bytes([0x12, 0x34, 0x56], byteorder='big') = 1193046
//   // Python: ir_led_data = int.from_bytes([0x78, 0x9A, 0xBC], byteorder='big') = 7905980
//   final pythonRedExpected = 1193046;  // 0x123456
//   final pythonIrExpected = 7903932;   // 0x789ABC
  
//   print('\n比较结果:');
//   print('Red LED - Dart: $redLedData, Python: $pythonRedExpected, 匹配: ${redLedData == pythonRedExpected}');
//   print('IR LED - Dart: $irLedData, Python: $pythonIrExpected, 匹配: ${irLedData == pythonIrExpected}');
// }